package com.tengju.user.infrastructure.repository.sign;

import com.tengju.user.domain.model.archive.sign.SignLog;
import com.tengju.user.domain.model.archive.sign.SignLogRepository;
import com.tengju.user.domain.model.user.UserIdCode;
import com.tengju.user.infrastructure.persistence.mybatis.dataobject.SignLogDO;
import com.tengju.user.infrastructure.persistence.mybatis.mapper.dealer.generate.SignLogDOMapper;
import com.tengju.user.infrastructure.repository.convert.SignLogConvert;
import org.springframework.stereotype.Repository;

@Repository
public class SignLogRepositoryImpl implements SignLogRepository {

    private final SignLogDOMapper signLogDOMapper;

    public SignLogRepositoryImpl(SignLogDOMapper signLogDOMapper) {
        this.signLogDOMapper = signLogDOMapper;
    }

    @Override
    public int save(SignLog signLog) {
        SignLogDO signLogDO = SignLogConvert.convert(signLog);
        return signLogDOMapper.insertSelective(signLogDO);
    }

    @Override
    public int count(UserIdCode idCode, String operateType, String lastIdentity) {
        return signLogDOMapper.count(idCode.getValue(), operateType, lastIdentity);
    }
}
